<!---
Copyright: (c) 2006 The MachBlog Authors
Authors: Matt Woodward (mpwoodward@gmail.com) & Peter J. Farrell (pjf@maestropublishing.com)

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License. 
You may obtain a copy of the License at 

http://www.apache.org/licenses/LICENSE-2.0 

Unless required by applicable law or agreed to in writing, software 
distributed under the License is distributed on an "AS IS" BASIS, 
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
See the License for the specific language governing permissions and 
limitations under the License.

$Id: LoginGateway.cfc 1191 2007-07-14 17:42:46Z pfarrell $

Notes:
--->
<cfcomponent
	displayname="LoginGateway"
	output="false"
	hint="LoginGateway for MachBlog">

	<!---
	PROPERTIES
	--->
	<cfproperty name="datasource" type="org.machblog.datasource.Datasource" required="true" />
	<cfproperty name="userFacade" type="org.machblog.facades.UserFacade" required="true" />
	<cfproperty name="userDAO" type="org.machblog.user.UserDAO" required="true" />
	<cfproperty name="resourceBundleFacade" type="org.machblog.facades.ResourceBundleFacade" required="true" />
	<cfproperty name="userService" type="org.machblog.user.UserService" required="true" />
	
	<!---
	INITIALIZATION / CONFIGURATION
	--->
	<cffunction name="init" access="public" output="false" returntype="LoginGateway">
		<cfreturn this />
	</cffunction>
	
	<cffunction name="setDatasource" access="public" output="false" returntype="void"
		hint="Dependency: injected">
		<cfargument name="datasource" type="org.machblog.datasource.Datasource" required="true" />
		<cfset variables.datasource = arguments.datasource />
	</cffunction>
	<cffunction name="getDatasource" access="public" output="false" 
			returntype="org.machblog.datasource.Datasource">
		<cfreturn variables.datasource />
	</cffunction>
	
	<cffunction name="setUserFacade" access="public" output="false" returntype="void"
		hint="Dependency: injected">
		<cfargument name="userFacade" type="org.machblog.facades.UserFacade" required="true" />
		<cfset variables.userFacade = arguments.userFacade />
	</cffunction>
	<cffunction name="getUserFacade" access="public" output="false" 
			returntype="org.machblog.facades.UserFacade">
		<cfreturn variables.userFacade />
	</cffunction>

	<cffunction name="setResourceBundleFacade" access="public" output="false" returntype="void"
		hint="Dependency: injected">
		<cfargument name="resourceBundleFacade" type="org.machblog.facades.ResourceBundleFacade" required="true" />
		<cfset variables.resourceBundleFacade = arguments.resourceBundleFacade />
	</cffunction>
	<cffunction name="getResourceBundleFacade" access="public" output="false" 
			returntype="org.machblog.facades.ResourceBundleFacade">
		<cfreturn variables.resourceBundleFacade />
	</cffunction>
	
	<cffunction name="setUserService" access="public" output="false" returntype="void">
		<cfargument name="userService" type="org.machblog.user.UserService" required="true" />
		<cfset variables.userService = arguments.userService />
	</cffunction>
	<cffunction name="getUserService" access="public" output="false" returntype="org.machblog.user.UserService">
		<cfreturn variables.userService />
	</cffunction>
	
	<!---
	PUBLIC FUNCTIONS
	--->
	<cffunction name="validateLogin" access="public" output="false" returntype="boolean" 
		hint="Validates the login based on the email and password passed in">
		<cfargument name="email" type="string" required="true" />
		<cfargument name="password" type="string" required="true" />
	</cffunction>

	<cffunction name="checkEmailExists" access="public" output="false" returntype="boolean" 
		hint="Checks to see if the email address passed in exists as a user in the system">
		<cfargument name="email" type="string" required="true" />
	</cffunction>
	
	<cffunction name="logout" access="public" output="false" returntype="void"
		hint="Logs the user out by removing the user via the UserFacade">
	</cffunction>

</cfcomponent>